package com.example.myapplication.Adapter;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import java.util.List;

//创建ViewPager盛放Fragment的适配器类
public class MyViewPagerAdapter extends FragmentPagerAdapter{
    private List<Fragment> list;
    public MyViewPagerAdapter(FragmentManager fm, List<Fragment> list) {
        super(fm);
        this.list = list;
    }

    //返回每个position对应的Fragment对象
    @Override
    public Fragment getItem(int position) {
        return list.get(position);
    }

    //返回list的长度，也就是Fragment对象的个数
    @Override
    public int getCount() {
        return list.size();
    }
}
